//************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// It is a target which manages all observers
///</describe>
/// <date>2024/5/6</date>
///***********************************************************************
#ifndef TARGET_H
#define TARGET_H

#include <mutex>
#include <vector>
#include <list>
#include "ITarget.h"
#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    class CLASS_ITEM Target : public ITarget
    {
    public:
        // Construct the obj
        Target();

        // Destruct the obj
        virtual ~Target();

    private:
        // Copy construct
        Target(const Target& other) = delete;

        // Assignment
        Target& operator=(const Target& other) = delete;

    public:
        // Add observer(Target do it)
        virtual void Add(IObserver *pObserver);

        // Remove the observer(Target do it)
        virtual void Remove(IObserver *pObserver);

        // Post Target(Target do it)
        virtual void Post(NotifyArgs& Args);

    private:
        // List lock
        std::mutex *m_pLock = nullptr;

        // Observer list
        std::vector<IObserver*> *m_pObserverContainer = nullptr;
    };
}

#endif // TARGET_H
